package com.stage3.zmy.exam4.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stage3.zmy.exam4.bean.Project;
import com.stage3.zmy.exam4.dao.ProjectDAO;
import com.stage3.zmy.exam4.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @PROJECT_NAME：stage3_exam4_zhangmengyao
 * @author： zhangyaoyao
 * @date： 2020/1/6 14:32
 * @ 听说你要在海边买一所房子和 你可爱的松子一起住在哪里
 */
@Service
public class ProjectServiceImpl implements ProjectService {
    @Autowired
    private ProjectDAO projectDAO;
    @Override
    public PageInfo<Project> getProjects(Integer pageIndex, Integer pageSize, String type, String account, Date startTime, Date endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        System.out.println("zmy"+type+"/"+account+"/"+startTime+"/"+endTime);
        List<Project> projects = projectDAO.getProjects(type, account, startTime, endTime);
        System.out.println(projects.size()+"ssss");
        PageInfo<Project> projectPageInfo = new PageInfo<>(projects);
        System.out.println(projectPageInfo.getSize()+"--size---");
        return   projectPageInfo;
    }

    @Override
    public List<String> getTypes() {
        return projectDAO.getTypes();
    }

    @Override
    public int updateProject(Project project) {
        return projectDAO.updateProject(project);
    }

    @Override
    public Project findProjectById(Integer id) {
        return projectDAO.findProjectById(id);
    }
}
